# from tortoise import Tortoise
# from tortoise.models import Model
from tortoise import Model,fields

class Teacher(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=20,description="教师名称")

class Classes(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=20,description="班级名称")

class Course(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=20,description="课程名称")
    address = fields.CharField(max_length=20,description="课程地址")
    teacher = fields.ForeignKeyField('models.Teacher', related_name='courses')

class Student(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(max_length=20,description="学生名称")
    age = fields.IntField(description="学生年龄")
    gender = fields.CharField(max_length=10,description="学生性别")
    create_time = fields.DatetimeField(auto_now_add=True,description="创建时间")
    # 一对多关系
    classes = fields.ForeignKeyField('models.Classes', related_name='students')
    # 多对多关系
    courses = fields.ManyToManyField('models.Course', related_name='students')

